<template>
  <div id="periodicals" :class="{ h5: this.$store.state.webType === 'h5' }">
    <el-row :span="24" class="page">
      <!-- 面包屑 -->
      <el-breadcrumb separator-class="el-icon-arrow-right">
        <el-breadcrumb-item :to="{ path: '/' }">{{
            $t('home')
          }}
        </el-breadcrumb-item>
        <el-breadcrumb-item>{{ $t('magazine') }}</el-breadcrumb-item>
      </el-breadcrumb>

      <div class="banner-view">
        <div class="big-col">
          <!-- {{$t('latest')}} -->
          <div class="book-view">
            <div class="book-content">
              <div class="view-label">
                <span>{{ $t('latest') }}</span>
              </div>
              <div class="book-row">
                <div>
                  <img class="book-img" :src="$store.state.newBook.imgUrl"/>
                </div>
                <div class="book-text">
                  <div class="text-item">
                    <div class="item-title title-one">{{ $t('contents') }}</div>
                  </div>
                  <div
                    class="text-item"
                    :class="{ none: !text.title }"
                    v-for="(text, tdx) in $store.state.newBook.muLu"
                    :key="tdx"
                  >
                    <div class="item-title" v-if="text.title">
                      {{ text.title }}
                    </div>
                    <div class="item-content">
                      {{ text.titleP }}
                    </div>
                  </div>

                  <div class="buy-btn" @click="this.$goShopping">
                    {{ $t('subscribe2') }}
                  </div>
                </div>
              </div>
            </div>
          </div>
        </div>
        <div class="small-col" v-if="$store.state.webType !== 'h5'">
          <img
            v-if="$store.state.lang == 'CN'"
            src="@/assets/images/qk/qk-df.png"
            alt=""
          />
          <img v-else src="@/assets/images/qk/qk-df-en.png" alt=""/>
        </div>
      </div>
    </el-row>
    <div class="page-content">
      <div class="art-col">
        <div class="view-label">
          <span @click="changeLabel('', '')">{{ $t('issues') }}</span>
          <div class="art-tab">
            <template v-if="labelData && labelData.length > 0">
              <div
                class="tab-item"
                @click="changeLabel(item.id, item.label)"
                :class="{ active: currentLabel == item.label }"
                v-for="(item, index) in labelData"
                :key="index"
              >
                {{ item.label }}
              </div>
            </template>
            <!-- 右侧切换视图和总条数 -->
            <!--            <div class="tab-info">-->
            <!--              <div class="info-total">-->
            <!--                {{-->
            <!--                  $t('results').length > 6-->
            <!--                    ? listTotal + '  ' + $t('results')-->
            <!--                    : `共 ${listTotal} 条`-->
            <!--                }}-->
            <!--              </div>-->
            <!--            </div>-->
          </div>
        </div>

        <div class="art-view">
          <template v-if="currentView === 'img'">
            <template v-for="(img, idx) in artData">
              <div class="art-item" v-if="img.id != $store.state.newBook.id" :key="idx">
                <router-link
                  target="_blank"
                  :to="{ path: '/book', query: { link: img.link } }"
                >
                  <img :src="img.imgUrl" :alt="img.title"/>
                  <div class="art-content">
                    <div class="item-title">
                      {{ img.title }}
                    </div>
                  </div>
                </router-link>
              </div>
            </template>
          </template>

          <!-- <goTop></goTop> -->
        </div>
        <!-- <div class="art-more true">{{$t("more2")}} ></div>
        <div v-if="false" class="art-more none">{{$t("noMore")}}</div> -->
      </div>
    </div>
    <div class="banner-view">
      <div class="small-col" v-if="$store.state.webType === 'h5'">
        <img
          v-if="$store.state.lang == 'CN'"
          src="@/assets/images/qk/qk-df.png"
          alt=""
        />
        <img v-else src="@/assets/images/qk/qk-df-en.png" alt=""/>
      </div>
    </div>
  </div>
</template>

<script>
import goTop from '../components/goTop';

export default {
  name: 'CharacterStory',
  components: {
    goTop,
  },
  data() {
    return {
      currentView: 'img',
      bannerData: [],
      bookData: {
        imgUrl: '',
        textList: [
          // {
          //   title: "卷首发布",
          //   content:
          //     "在庆祝香港回归祖国25周年大会暨香港特别行政区第六届政府就职典礼上的讲话",
          // },
          // {
          //   title: "读懂中国",
          //   content: "永远的朋友 真诚的伙伴--寨中关系更进一步",
          // },
        ],
      },
      artData: [],
      // 文章列表请求信息
      listQuery: {
        columnId: '',
        labelId: '',
        pageSize: 100,
        pageNum: 1,
      },
      token: false,
      labelData: [],
      currentLabel: '',
    };
  },
  mounted() {
    if (this.$route.query.token) {
      this.token = true;
      sessionStorage.setItem('token', this.$route.query.token);
    }
    this.listQuery.columnId = this.$getPartId(this.$route.path);
    this.listQuery.menuId = this.$getMenuId(this.$route.path);
    this.getLabels();
  },
  methods: {
    getList() {
      this.$get(this.$api + '/cms/web/selsctWeb', this.listQuery)
        .then(
          (res) => {
            this.artData = [...this.artData, ...res.data];
            // this.bookData = Object.assign({}, res.data[0]);
            this.listTotal = res.total;
            this.maxPage = res.maxPage;
          }
        );
    },
    getLabels() {
      this.$get(this.$api + '/cms/web/getLabelByPartId', {
        partId: this.listQuery.columnId,
      })
        .then((res) => {
          this.labelData = res.data;
        })
        .then((res) => {
          this.listQuery.labelId = this.labelData[0].id;
          this.listQuery.label = this.labelData[0].label;
          this.currentLabel = this.labelData[0].label;
          this.getList();
        });
    },
    changeLabel(id, label) {
      this.listQuery.labelId = id;
      this.listQuery.pageNum = 1;
      this.listQuery.label = label;
      this.currentLabel = label;
      this.artData = [];
      this.getList();
    },
    viewTypeChange(type) {
      this.currentView = type;
    },
  },
};
</script>

<style lang="scss" scoped>
#periodicals.h5 {
  .art-col .view-label span:after {
    width: fw(22vw, h5);
    height: fh(10vh, h5);
    bottom: fh(-4vh, h5);
    right: fw(-6vw, h5);
    border-right: fw(4vw, h5) solid #d6d6d6;
    border-bottom: fw(4vw, h5) solid #d6d6d6;
  }

  .banner-view .big-col .view-label span[data-v-c9265b3a]::after {
    width: fw(22vw, h5);
    height: fh(10vh, h5);
    bottom: fh(-4vh, h5);
    right: fw(-6vw, h5);
    border-right: fw(4vw, h5) solid #d6d6d6;
    border-bottom: fw(4vw, h5) solid #d6d6d6;
  }
}

img {
  width: fw(22vw, h5);
  bottom: fh(-6vh, h5);
  right: fw(-6vw, h5);
}

#periodicals {
  position: relative;
  width: 100%;

  &::after {
    // content: "";
    position: absolute;
    left: 0;
    top: 0;
    z-index: -1;
    width: 100%;
    height: 100%;
    background: url("../assets/images/qk-bg.png") no-repeat;
    background-size: 100% auto;
    background-position: center 0;
  }

  .page {
    padding: fh(152vh, pc) fw(80vw, pc) 0 fw(80vw, pc);
    background: linear-gradient(
        180deg,
        rgba(255, 255, 255, 0.13) 0%,
        #fff 100%
    );

    ::v-deep .el-breadcrumb {
      .el-breadcrumb__inner {
        font-weight: bold;
        color: #fff !important;
        font-size: fh(18vh, pc);
      }
    }
  }

  .page-content {
    background-color: rgba(255, 255, 255, 1);
    padding: 0 fw(80vw, pc) fh(40vh, pc) fw(80vw, pc);
  }

  .banner-view {
    width: 100%;
    margin: 0 auto;
    display: flex;
    align-items: flex-start;

    // padding-top: fh(20vh, pc);
    .big-col {
      width: fw(1180vw, pc);
      background-color: #f6f6f6;

      .view-label {
        color: $zh;
        width: 100%;
        position: relative;
        display: inline-block;
        font-size: fh(24vh, pc);
        font-weight: 800;
        padding: fh(40vh, pc) fw(40vw, pc);
        border-bottom: 2px solid rgba(151, 151, 151, 0.5);

        span {
          position: relative;

          &::after {
            content: "";
            position: absolute;
            bottom: fh(-10vh, pc);
            right: fw(-12vw, pc);
            width: fw(34vw, pc);
            height: fh(16vh, pc);
            border-right: fw(6vw, pc) solid #d6d6d6;
            border-bottom: fw(8vw, pc) solid #d6d6d6;
          }
        }
      }

      .book-content {
        // background: linear-gradient(
        //   180deg,
        //   rgba(255, 255, 255, 0.13) 0%,
        //   #ffffff 100%
        // );
        // padding-bottom: fh(40vh, pc);
        .book-row {
          position: relative;
          display: flex;
          width: 100%;
          padding: fh(18vh, pc) fw(40vw, pc);
          padding-bottom: fh(60vh, pc);
          color: $sh;

          .buy-btn {
            min-width: fw(120vw, pc);
            position: absolute;
            bottom: fh(40vh, pc);
            right: fw(40vw, pc);
            width: fw(120vw, pc);
            height: fh(48vh, pc);
            line-height: fh(48vh, pc);
            background: #0046b4;
            bottom: fh(20vh, pc);
            color: #fff;
            text-align: center;
            border-radius: 4px;

            &:hover {
              opacity: 0.8;
            }
          }

          img.book-img {
            width: fw(400vw, pc);
            height: auto;
          }

          .book-text {
            flex: 1;
            padding-left: fw(40vw, pc);

            .text-item {
              padding-bottom: fh(36vh, pc);

              &.none {
                margin-top: fh(-30vh, pc);
              }

              .item-title {
                color: $sh;
                font-size: fh(16vh, pc);
                font-weight: bold;
                padding-bottom: fh(20vh, pc);

                &.title-one {
                  font-size: fh(18vh, pc);
                }
              }

              .item-content {
                font-size: fh(14vh, pc);
                line-height: fh(26vh, pc);
              }

              &:nth-child(1) {
                padding-bottom: fh(25vh, pc);

                .item-title {
                  color: $sh;
                  padding-bottom: 0;
                }
              }
            }
          }
        }
      }
    }

    .small-col {
      position: relative;
      flex: 1;
      margin-left: fw(20vw, pc);

      img {
        position: absolute;
        left: 0;
        top: 0;
        width: 100%;
        display: block;
      }
    }
  }

  .art-col {
    position: relative;
    width: fw(1180vw, pc);

    .art-tab {
      flex: 1;
      display: flex;
      align-items: center;
      color: $sh;
      padding-left: 50px;

      .tab-info {
        margin-left: auto;
        display: flex;
        align-items: center;

        .toggle-img {
          margin-left: fh(62vw, pc);
          margin-right: fh(24vw, pc);
        }

        img {
          width: fw(20vw, pc);
          cursor: pointer;
        }
      }

      .tab-info {
        margin-left: auto;
        display: flex;
        align-items: center;

        .toggle-img {
          margin-left: fh(62vw, pc);
          margin-right: fh(24vw, pc);
        }

        img {
          width: fw(20vw, pc);
          cursor: pointer;
        }
      }

      .tab-item {
        margin-right: fw(60vw, pc);
        font-size: fh(16vh, pc);
        position: relative;
        line-height: fh(30vh, pc);

        &:hover {
          color: $sh;
          cursor: pointer;
        }

        &.active {
          font-size: fh(20vh, pc);
          font-weight: bold;
          color: $sh;

          &::before {
            content: "";
            position: absolute;
            bottom: fh(-14vh, pc);
            width: 100%;
            border-top: fh(6vh, pc) solid $zh;
          }
        }
      }
    }

    .view-label {
      color: $zh;
      width: 100%;
      display: flex;
      position: relative;
      font-size: fh(24vh, pc);
      font-weight: 800;
      padding: fh(40vh, pc) fw(40vw, pc);
      border-bottom: 2px solid rgba(151, 151, 151, 0.5);

      span {
        position: relative;

        &::after {
          content: "";
          position: absolute;
          bottom: fh(-10vh, pc);
          right: fw(-12vw, pc);
          width: fw(34vw, pc);
          height: fh(16vh, pc);
          border-right: fw(6vw, pc) solid #d6d6d6;
          border-bottom: fw(8vw, pc) solid #d6d6d6;
        }
      }
    }

    .art-view {
      position: relative;
      width: 100%;
      display: flex;
      flex-wrap: wrap;
      justify-content: baseline;
      padding: fh(34vh, pc) fw(40vw, pc);

      &.text {
        .item-title {
          color: $sh;
          display: flex;
          width: 100%;

          .item-info {
            margin-left: auto;
            width: auto !important;

            .info-time {
              margin-left: fh(60vh, pc);
            }
          }
        }
      }

      .art-item {
        width: fw(260vw, pc);
        margin-bottom: fh(20vh, pc);
        // background-color: $dh;
        margin-right: fw(20vw, pc);
        cursor: pointer;

        &:nth-child(4n + 0) {
          margin-right: 0;
        }

        img {
          width: 100%;
        }

        .art-content {
          width: 100%;
          color: rgba(251, 254, 255, 0.8);
          padding: fh(20vh, pc) fw(20vw, pc);

          .item-title {
            color: $sh;
            text-align: center;
            font-size: fh(14vh, pc);
            // margin-bottom: fh(8vh, pc);
            // font-weight: 600;
            color: #000;
          }

          .item-info {
            display: flex;
            align-items: center;
            width: 100%;
            justify-content: space-between;
            margin-bottom: fh(0vh, pc);
            font-size: fh(14vh, pc);
            line-height: fh(20vh, pc);

            .info-time {
              color: #a1b8bd;
            }
          }

          .item-content {
            font-size: fh(14vh, pc);
            line-height: fh(20vh, pc);
            font-weight: 400;
            width: 100%;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
          }
        }
      }
    }

    .art-more {
      width: max-content;
      margin: fh(40vh, pc) auto;
      color: $sh;
      font-size: fh(14vh, pc);

      &.true:hover {
        cursor: pointer;
        opacity: 0.8;
        color: $zh;
      }

      &.none {
        opacity: 0.5;
      }
    }
  }
}

#periodicals.h5 {
  .art-col {
    width: 100%;

    .art-view {
      padding-bottom: 0;

      .art-item {
        width: 48.5%;

        img {
          display: block;
          width: 100%;
        }
      }
    }
  }

  .banner-view {
    flex-wrap: wrap;

    .small-col {
      img {
        position: relative;
      }
    }

    .big-col {
      width: 100%;

      .book-content .book-row {
        flex-wrap: wrap;

        .buy-btn {
          width: fw(100vw, h5);
        }

        img.book-img {
          width: 100%;
          height: auto;
          margin: 0 auto;
        }

        .book-text {
          padding-top: fh(20vh, h5);
          width: 100%;
          flex: none;
        }
      }
    }
  }
}
</style>

